package com.own.component.sharding.config;

import com.own.component.sharding.util.ShardingUtil;
import org.springframework.boot.CommandLineRunner;
import org.springframework.core.annotation.Order;
import org.springframework.stereotype.Component;

import javax.annotation.Resource;

/**
 * ShardingTablesLoadRunner
 *
 * @author chenxueli
 * @date 2023-07-19 16:38:00
 */
@Order(value = 1)
@Component
public class ShardingTablesLoadRunner implements CommandLineRunner {

    @Resource
    private ShardingUtil shardingUtil;

    @Override
    public void run(String... args) {
        // 读取已有分表，进行缓存
        var list = shardingUtil.listTableNames();
        // 缓存所有的分表信息

        list.forEach(System.out::println);
    }

}